/*
 * File     : Function.java
 * Created  : 1 May 2011
 *
 * Copyright © 2011 Matthew Wilson (mj. {my-surname} .uk {at} gmail.com)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.googlecode.dni;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;


/**
 * <p>
 *  Annotates a method of a native interface that maps to a native function.
 * </p>
 *
 * @author Matthew Wilson
 */
@Retention( RetentionPolicy.RUNTIME )
@Target( ElementType.METHOD )
@Documented
public @interface Function
{

    /**
     * Special pseudo-character-set name for the default library character set.
     */
    String LIBRARY_CHARSET = "##library##";

    /**
     * <p>
     *  The native name of the function.
     * </p>
     * <p>
     *  The default name (if this property is not set) will be taken from the
     *  method name.  Name "mangling" by the calling convention is done after
     *  the base name is determined.
     * </p>
     *
     * @return the name, or an empty string to use the default name
     */
    String name() default "";

    /**
     * <p>
     *  Whether to mangle the name of the function.
     * </p>
     * <p>
     *  By default, the calling convention is allowed to "mangle" the name of the
     *  function.  If this property is set to <code>false</code>, that mangling
     *  does not occur; hence, you will need to set the mangled name in the
     *  {@link #name()} property.
     * </p>
     *
     * @return whether to mangle the name
     */
    boolean mangleName() default true;

    /**
     * <p>
     *  The character set name to use.
     * </p>
     * <p>
     *  By default, the platform character set is chosen.
     * </p>
     *
     * @return the character set name
     */
    String charset() default LIBRARY_CHARSET;

}
